<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var arr = [1, 2, 9, 3, 4, 5, 6, 7, 8, 9];
        // 查找9的索引号
        console.log(arr.indexOf(9));
        // indexOf()是从前面往后面查询元素的
        console.log(arr.lastIndexOf(9));
        // lastIndexOf()是从后面查询到前面的
        console.log(arr.indexOf(100));
        console.log(arr.lastIndexOf(100));
        // indexOf() 跟lastIndexOf() 查询数组中没有的元素即返回 - 1;
    </script>
</head>

<body>

</body>

</html>